<!DOCTYPE html>
<html>
<head>
	<meta charset="UTF-8">
	<meta name="viewport" content="width=device-width, initial-scale=1.0, maximum-scale=1.0, minxmum-scale=1.0, user-scalable=no, minimal-ui">
    <meta content="yes" name="apple-mobile-web-app-capable">
    <meta name="apple-mobile-web-app-status-bar-style" content="black-translucent">
    <meta content="black" name="apple-mobile-web-app-status-bar-style">
    <meta name="format-detection" content="telephone=no">
    <meta name="full-screen" content="yes">
    <meta name="x5-fullscreen" content="true">
    <meta http-equiv="Pragma" content="no-cache">
    <meta http-equiv="Cache-control" content="no-cache">
    <meta http-equiv="Cache" content="no-cache"> 
	<title>微信开发</title>
	<link rel="stylesheet" href="/js/weui.min.css">
	<link rel="stylesheet" href="/js/base.css">
	<link rel="stylesheet" type="text/css" href="/js/jquery-weui.min.css">
</head>
<style type="text/css">
	.min{
		margin: 100px auto;
		display: flex;
		justify-content: space-around;
	}
	.btn {
		width: 80px;
	    border: 1px solid #ccc;
	    height: 35px;
	    border-radius: 50px;
	    line-height: 35px;
	    text-align: center;
	    cursor: pointer;
	}
	.img {
		text-align: center;
		width: auto;
	}
	img{
		width: auto;
		max-height: 100px;
	}
</style>
<body>

	<div class="min">
		<!-- <div class="btn share">分享</div> -->
		<div class="btn pic">上传头像</div>
		<div class="btn pay">支付</div>
	</div>

	<div class="img">
		<img src="<?php echo (isset($_SESSION['imgUrl'])&&$_SESSION['imgUrl'])?$_SESSION['imgUrl']:'/img/login_head_girl@3x.png';?>" id="headimg">
	</div>

</body>
<script type="text/javascript" src="/js/jquery-2.1.4.js"></script>
<script type="text/javascript" src="/js/jquery-weui.min.js"></script>
<script src="http://res.wx.qq.com/open/js/jweixin-1.4.0.js"></script>
<script type="text/javascript" src="/js/we.js?v=3"></script>
<script type="text/javascript">
	//分享
	var burl=window.location.href;
	var imgurl="<?php echo base_url().'img/login_head_girl@3x.png';?>";
	sharePerson('这是title','这是desc',burl,imgurl);


	//上传头像
	$('.pic').on('click',function(){

		$.actions({
			actions: [{
			    text: "相册",
			    onClick: function() {
			      //do something
			      selectAlbum(upload);
			    }
			},{
			    text: "拍照",
			    onClick: function() {
			      //do something
			      selectCamera(upload);
			    }
			}]
		});
	})

	//图片上传到自己的服务器
	// function uploadImage(serverId){
	function upload(serverId){
		$.ajax({
			url:'/Upload/downloadWxImage',
			type:'post',
			data:{'media_id':serverId},
			dataType:'json',
			success:function(json){
				if (json.code == 1) {
					alert('上传成功');
					saveImg(json.url);
				}else{
					alert('上传失败');
				}
			}
		})
	}

	// 保存图片到数据库
	function saveImg(url){
		$.ajax({
			url:'/Upload/saveUploadImg',
			type:'post',
			data:{'url':url},
			dataType:'json',
			success:function(json){
				// if (json.code == 1) {
					$('#headimg').prop('src',url);
				// }else{
				// 	alert('保存失败');
				// }
			}
		})
	}


	//支付
	$('.pay').on('click',function(){
		// window.location.href="/WxPay/index";
		window.location.href="/Weixin/Pay/index";
	})
</script>
</html>